import Vue from 'vue';
import App from './App.vue';
import './registerServiceWorker';
import router from './router/index.js';
import store from './store/index.js';
// import 'vant/lib/index.css';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import '@/assets/css/public.css';
// import { Lazyload } from 'vant';
import '@vant/touch-emulator';

Vue.config.productionTip = false;
// Vue.use(Lazyload, {
//   lazyComponent: true,
// });

// 进度条
NProgress.inc(0.2);
NProgress.configure({ easing: 'ease', speed: 500, showSpinner: false });
router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});
router.afterEach(() => {
  NProgress.done();
});

// import Vconsole from 'vconsole'
// let vConsole = new Vconsole()
// Vue.use(vConsole)

router.beforeEach((to, from, next) => {
  // 动态设置favicon
  let link =
    document.querySelector("link[rel*='icon']") ||
    document.createElement('link');
  link.type = 'image/x-icon';
  link.rel = 'icon';
  link.href = '/icons/favicon.ico';
  document.getElementsByTagName('head')[0].appendChild(link);
  // 动态设置title
  document.title = 'vue示例模板';
  next();
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');
